package com.shuyuntu.proposal.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;

/**
 * 描述附件信息的Entity
 * Created by limeng on 16/5/17.
 */

@Entity
@Table(name = "attachment")
public class Attachment {
    /**
     * 附件的id
     */
    private Integer id;
    /**
     * 附件的名字
     */
    private String filename;

    /**
     * 附件的真实名字
     */
    private String realName;

    /**
     * 附件保存的路径
     */
    private String path;
    /**
     * 附件的大小(单位为MB)
     */
    private Float size;
    /**
     * 所属的提案
     */
    @JsonIgnore
    private Proposal proposal;

    public Attachment() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(nullable = false, length = 80)
    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    @Column(nullable = false, length = 255)
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @Column(nullable = false)
    public Float getSize() {
        return size;
    }

    public void setSize(Float size) {
        this.size = size;
    }

    @ManyToOne
    @JoinColumn(name = "proposal_id", referencedColumnName = "id")
    public Proposal getProposal() {
        return proposal;
    }

    public void setProposal(Proposal proposal) {
        this.proposal = proposal;
    }

    @Column(name = "real_name")
    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }
}
